package org.kele.k8s.sc2020.provider.controller;

import lombok.extern.slf4j.Slf4j;
import org.kele.k8s.sc2020.api.ProviderDemoApi;
import org.kele.k8s.sc2020.provider.service.IEmployeeService;
import org.kele.k8s.sc2020.provider.uitl.EmployeeTransfer;
import org.kele.k8s.sc2020.vo.EmployeeDTO;
import org.kele.k8s.sc2020.vo.KeleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class ProviderDemoController implements ProviderDemoApi {

    @Override
    public KeleResponse<String> getKeleInfo() {
        return KeleResponse.okBean("hello i am 徐可乐");
    }

    @Autowired
    IEmployeeService empService;

    @Override
    public KeleResponse<EmployeeDTO> getEmpById(@PathVariable Integer uid) {
        log.info("query at api id={} ", uid);
        return KeleResponse.okBean(EmployeeTransfer.convertToDTO(empService.getById(uid)));
    }
}
